static int vmx_alloc_vlapic_mapping(struct domain *d);
static void vmx_free_vlapic_mapping(struct domain *d);
-static int vmx_alloc_vpid(struct domain *d);
-static void vmx_free_vpid(struct domain *d);
+static int vmx_alloc_vpid(struct vcpu *v);
+static void vmx_free_vpid(struct vcpu *v);
static void vmx_install_vlapic_mapping(struct vcpu *v);
static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr);
static void vmx_update_guest_efer(struct vcpu *v);
d->arch.hvm_domain.vmx.ept_control.asr =
pagetable_get_pfn(d->arch.phys_table);
- if ( (rc = vmx_alloc_vpid(d)) != 0 )
- return rc;
if ( (rc = vmx_alloc_vlapic_mapping(d)) != 0 )
- {
- vmx_free_vpid(d);
return rc;
- }
return 0;
}
{
ept_sync_domain(d);
vmx_free_vlapic_mapping(d);
- vmx_free_vpid(d);
}
static int vmx_vcpu_initialise(struct vcpu *v)
spin_lock_init(&v->arch.hvm_vmx.vmcs_lock);
+ if ( (rc = vmx_alloc_vpid(v)) != 0 )
+ return rc;
+
v->arch.schedule_tail = vmx_do_resume;
v->arch.ctxt_switch_from = vmx_ctxt_switch_from;
v->arch.ctxt_switch_to = vmx_ctxt_switch_to;
dprintk(XENLOG_WARNING,
"Failed to create VMCS for vcpu %d: err=%d.\n",
v->vcpu_id, rc);
+ vmx_free_vpid(v);
return rc;
}
vmx_destroy_vmcs(v);
vpmu_destroy(v);
passive_domain_destroy(v);
+ vmx_free_vpid(v);
}
#ifdef __x86_64__
};
static unsigned long *vpid_bitmap;
-#define VPID_BITMAP_SIZE ((1u << VMCS_VPID_WIDTH) / XEN_LEGACY_MAX_VCPUS)
+#define VPID_BITMAP_SIZE (1u << VMCS_VPID_WIDTH)
void start_vmx(void)
{
free_xenheap_page(mfn_to_virt(mfn));
}
-static int vmx_alloc_vpid(struct domain *d)
+static int vmx_alloc_vpid(struct vcpu *v)
{
int idx;
}
while ( test_and_set_bit(idx, vpid_bitmap) );
- d->arch.hvm_domain.vmx.vpid_base = idx * XEN_LEGACY_MAX_VCPUS;
+ v->arch.hvm_vmx.vpid = idx;
return 0;
}
-static void vmx_free_vpid(struct domain *d)
+static void vmx_free_vpid(struct vcpu *v)
{
if ( !cpu_has_vmx_vpid )
return;
- clear_bit(d->arch.hvm_domain.vmx.vpid_base / XEN_LEGACY_MAX_VCPUS,
- vpid_bitmap);
+ if ( v->arch.hvm_vmx.vpid )
+ clear_bit(v->arch.hvm_vmx.vpid, vpid_bitmap);
}
static void vmx_install_vlapic_mapping(struct vcpu *v)